<template>
  <div>
      <h1>全部图书展示</h1>
      <p v-for="(i,j) in nr" :key="j">
        <a :href="'/#/books_xq/?id='+i.id"> {{i.name}}</a> 
      </p>
      <el-pagination
      :page-size="2"
      :total="total"
      @current-change = 'fanye'
      ></el-pagination>

  </div>
</template>

<script>
import axios from 'axios'
export default {
  data() {
    return {
      baseurl:'http://127.0.0.1:8000',
      nr:[],
      total:0,
      id:sessionStorage.getItem('id'),
      user:sessionStorage.getItem('user')

    }
  },
  methods:{
      fanye(page){
          axios({
          url:'http://127.0.0.1:8000/app01/books/?page='+page,
          method:'get',
        }).then(res=>{
          console.log(res.data)
          this.nr = res.data.ca
          this.total = res.data.total
        })
      },
      jiazai(){
        axios({
          url:'http://127.0.0.1:8000/app01/books/',
          method:'get',
        }).then(res=>{
          console.log(res.data)
          this.nr = res.data.ca
          this.total = res.data.total
        })
      }
  },
  created(){
      axios({
          url:'http://127.0.0.1:8000/app01/books/',
          method:'get',
        }).then(res=>{
          console.log(res.data)
          this.nr = res.data.ca
          this.total = res.data.total
          
        })
  }

}
</script>

<style>

</style>